/// <license>
/// This software and are provided as-is and without  warranty. 
/// This is  free  software,  as long  as you  clearly  display
/// the original author and his company for at least  1  second
/// on the attached display. If you need a commercial   license 
/// in which you do not have these restrictions, please contact
/// us via our website.
/// 
/// Author: Mario Di Vece
/// Unosquare S.A. de C.V. Copyright (c) 2013
/// url: http://www.unosquare.com
/// </license>

namespace Unosquare.Labs.Drivers.Vizic
{
    using System;
    using Microsoft.SPOT;

    /// <summary>
    /// An object that is drawable in a scene. Inherit from this class to implement your own scene objects
    /// </summary>
    public abstract class VizicSceneObjectBase
    {
        protected VizicSceneObjectBase(VizicSceneBase scene)
        {
            this.Scene = scene;
        }

        protected VizicSceneBase Scene { get; set; }
        public ushort X { get; set; }
        public ushort Y { get; set; }
        public ushort Width { get; set; }
        public ushort Height { get; set; }

        /// <summary>
        /// Draws this instance.
        /// </summary>
        public abstract void Draw();

        /// <summary>
        /// Invalidates this instance. (i.e. clears the area before it gets updated)
        /// </summary>
        public virtual void Invalidate()
        {
            this.Scene.LCD.ForegroundColor = this.Scene.BackgroundColor;
            this.Scene.LCD.FillBackground = true;
            this.Scene.LCD.DrawRectangle(X, Y, Width, Height);
        }
    }
}
